<!--订单进度-->
<div style="height:15px;"></div>
<table class="layui-table">
<thead>
	<tr class="layui-bg-orange">
		<th width="20%"><a href="javascript:showDetail('采购中-订单列表', '{:url('', '_ajax=1&fun=_getDdjd&detail=1&factory_id='.$thisFactoryId.'&from='.$thisFrom)}')" style="text-decoration:underline">采购中</a></th>
		<th width="20%"><a href="javascript:showDetail('面料处理-订单列表', '{:url('', '_ajax=1&fun=_getDdjd&detail=2&factory_id='.$thisFactoryId.'&from='.$thisFrom)}')" style="text-decoration:underline">面料处理</a></th>
		<th width="15%"><a href="javascript:showDetail('裁剪中-订单列表', '{:url('', '_ajax=1&fun=_getDdjd&detail=3&factory_id='.$thisFactoryId.'&from='.$thisFrom)}')" style="text-decoration:underline">裁剪中</a></th>
		<th width="15%"><a href="javascript:showDetail('车缝中-订单列表', '{:url('', '_ajax=1&fun=_getDdjd&detail=4&factory_id='.$thisFactoryId.'&from='.$thisFrom)}')" style="text-decoration:underline">车缝中</a></th>
		<th width="15%"><a href="javascript:showDetail('尾部中-订单列表', '{:url('', '_ajax=1&fun=_getDdjd&detail=5&factory_id='.$thisFactoryId.'&from='.$thisFrom)}')" style="text-decoration:underline">尾部中</a></th>
		<th width="15%"><a href="javascript:showDetail('JIT-订单列表', '{:url('', '_ajax=1&fun=_getDdjd&detail=6&factory_id='.$thisFactoryId.'&from='.$thisFrom)}')" style="text-decoration:underline">JIT数</a></th>
	</tr>
</thead>
<tbody>
	<td class="value" style="text-decoration:underline;cursor:pointer;" onclick="getChart7daysJianshu('cg')">
		<span id="caigou_jianshu">0</span>件/<span id="caigou_order_count">0</span>单<br>
		昨日：<span id="caigou_jianshu_yestoday">0</span>件/<span id="caigou_order_count_yestoday">0</span>单
	</td>
	<td class="value" style="text-decoration:underline;cursor:pointer;" onclick="getChart7daysJianshu('ml')">
		<span id="material_jianshu">0</span>件/<span id="material_order_count">0</span>单<br>
		昨日：<span id="material_jianshu_yestoday">0</span>件/<span id="material_order_count_yestoday">0</span>单
	</td>
	<td class="value" style="text-decoration:underline;cursor:pointer;" onclick="getChart7daysJianshu('cj')">
		<span id="caijian_jianshu">0</span>件/<span id="caijian_order_count">0</span>单<br>
		昨日：<span id="caijian_jianshu_yestoday">0</span>件/<span id="caijian_order_count_yestoday">0</span>单
	</td>
	<td class="value" style="text-decoration:underline;cursor:pointer;;" onclick="getChart7daysJianshu('chej')">
		<span id="chejian_jianshu">0</span>件/<span id="chejian_order_count">0</span>单<br>
		昨日：<span id="chejian_jianshu_yestoday">0</span>件/<span id="chejian_order_count_yestoday">0</span>单<br>
		<!-- 未：<span id="chejian_weikaihuo">0</span>&nbsp;
		进：<span id="chejian_yikaihuo">0</span>&nbsp;
		完：<span id="chejian_yiwancheng">0</span> -->
	</td>
	<td class="value" style="text-decoration:underline;cursor:pointer;" onclick="getChart7daysJianshu('wb')">
			<span id="weibu_jianshu">0</span>件/<span id="weibu_order_count">0</span>单<br>
			昨日：<span id="weibu_jianshu_yestoday">0</span>件/<span id="weibu_order_count_yestoday">0</span>单
		</td>
		<td class="value"><span id="daichuhuo_jianshu">0</span>件/<span id="daichuhuo_order_count">0</span>单</td>
		</tr>
	</tbody>
</table>
<div id="chart_7days_jianshu"></div>

<script>
layui.use(['jquery', 'layer'], function() {
	var $ = layui.jquery;
	var layer = layui.layer;

	//订单进度
	window.getDdjd = function(){
		$.ajax({
			type: "POST",
			url: "?c=dailyV2&m=index",
			data: "_ajax=1&fun=_getDdjd&factory_id="+factoryId+"&from="+from,
			dataType: "json",
			success: function(res){
				if(res.code == 1){
					var d = res.data;
					$("#caigou_jianshu").html(d.cg[1]);
					$("#caigou_order_count").html(d.cg[2]);
					$("#caigou_jianshu_yestoday").html(d['yestoday']['cg']['jianshu']);
					$("#caigou_order_count_yestoday").html(d['yestoday']['cg']['order']);
	
					$("#material_jianshu").html(d.ml[1]);
					$("#material_order_count").html(d.ml[2]);
					$("#material_jianshu_yestoday").html(d['yestoday']['ml']['jianshu']);
					$("#material_order_count_yestoday").html(d['yestoday']['ml']['order']);
					
					$("#caijian_jianshu").html(d.cj[1]);
					$("#caijian_order_count").html(d.cj[2]);
					$("#caijian_jianshu_yestoday").html(d['yestoday']['cj']['jianshu']);
					$("#caijian_order_count_yestoday").html(d['yestoday']['cj']['order']);
	
					$("#chejian_jianshu").html(d.chej[1]);
					$("#chejian_order_count").html(d.chej[2]);
					$("#chejian_jianshu_yestoday").html(d['yestoday']['chej']['jianshu']);
					$("#chejian_order_count_yestoday").html(d['yestoday']['chej']['order']);
					/* $("#chejian_weikaihuo").html(d.chej.wkh);
					$("#chejian_yikaihuo").html(d.chej.jxz);
					$("#chejian_yiwancheng").html(d.chej.ywc); */
	
					$("#weibu_jianshu").html(d.wb[1]);
					$("#weibu_order_count").html(d.wb[2]);
					$("#weibu_jianshu_yestoday").html(d['yestoday']['wb']['jianshu']);
					$("#weibu_order_count_yestoday").html(d['yestoday']['wb']['order']);
	
					$("#daichuhuo_jianshu").html(d.dch[1]);
					$("#daichuhuo_order_count").html(d.dch[2]);
					/*$("#heji_jianshu").html(d.hj[1]);
					$("#heji_order_count").html(d.hj[2]);
					$("#heji_total_cost").html(d.hj[5]);*/
	
					/*$("#zhengdanwaifa").html(d.zdwf[1]);
	
					$("#caipianwaifa_caigou_jianshu").html(d.cpwf[1]);
					$("#caipianwaifa_caigou_order_count").html(d.cpwf[2]);
					$("#caipianwaifa_caijian_jianshu").html(d.cpwf[3]);
					$("#caipianwaifa_caijian_order_count").html(d.cpwf[4]);
					$("#caipianwaifa_heji_jianshu").html(d.cpwf[5]);
					$("#caipianwaifa_heji_order_count").html(d.cpwf[6]);*/
	
					//$("#part2_update_time").html(d.update_time);
				}else layer.msg(res.msg, {icon: 2,anim: 6});
			}
		});
	}
	
	// 获取不同环节近7天的完成件数
	window.getChart7daysJianshu = function(step) {
		$('#chart_7days_jianshu').html('加载中，请稍后...');
		$.ajax({
			type: "POST",
			url: "?c=dailyV2&m=index",
			data: "_ajax=1&fun=_getChart7daysJianshu&factory_id="+factoryId+"&step="+step+"&from="+from,
			dataType: "json",
			success: function(res){
				if(res.code == 1){
					var d = res.data;
	
					var chart = Highcharts.chart('chart_7days_jianshu', {
					    title: {
					        text: d['stepName']+'近7天完成件数',
					        x: -20 //center
					    },
					    xAxis: {
					        categories: d.days
					    },
					    yAxis: {
					        title: {
					            text: '件数'
					        },
					        plotLines: [{
					            value: d['avg'],
					            dashStyle: 'Dash',
					            width: 1,
					            color: '#ff0000',
					            label:{text:"平均值："+d['avg'],align:'left'},
					            zIndex: 99666565464
					        }]
					    },
					    legend: {
					        layout: 'vertical',
					        align: 'right',
					        verticalAlign: 'middle',
					        borderWidth: 0
					    },
						plotOptions: {
							line: {
								dataLabels: {
									enabled: true,         // 开启数据标签
									formatter: function() {
										return this.y
									}
								}
							},
							series: {
				                cursor: 'pointer',
				                point: {
				                    events: {
				                        // 数据点点击事件
				                        // 其中 e 变量为事件对象，this 为当前数据点对象
				                        click: function (e) {
				                            showOrders(e.point.category);
				                        }
				                    }
				                }
				            }
						},
					    series: d.stat
					});
	
				}else layer.msg(res.msg, {icon: 2,anim: 6});
			}
		});
	}
	
	getDdjd();		// 订单进度
	setInterval("getDdjd()", 600000); 		// 10分钟
});
</script>